//
//  ChartsTableViewCell.m
//  Mtime2.0
//
//  Created by 凉气的Mac on 16/9/21.
//  Copyright © 2016年 凉气的Mac. All rights reserved.
//

#import "ChartsTableViewCell.h"

#import "MtimeButton2.h"

#import <Masonry.h>

@interface ChartsTableViewCell ()

@property(nonatomic,strong)  NSArray *imageArray;

@property(nonatomic,strong)  NSArray *titleArray;

@end

@implementation ChartsTableViewCell

-(NSArray *)imageArray{
    
    if (_imageArray == nil) {
        
        _imageArray = @[[UIImage imageNamed:@"homepage_mallentry_ ranking"],[UIImage imageNamed:@"v10_ChineseTop100"],[UIImage imageNamed:@"v10_GlobalTopList"]];
        
    }
    
    return _imageArray;
}

-(NSArray *)titleArray{
    
    if (_titleArray == nil) {
        
        _titleArray = @[@"时光Top100",@"华语Top100",@"全球票房榜"];
        
    }
    
    return _titleArray;
}


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        [self setupUI];
        
    }
    
    return self;
}

#pragma mark --
#pragma mark --设置界面
-(void)setupUI{
    
    CGFloat margin = 40;
    
    CGFloat btnWH = (kScreen.size.width - 4 * margin) / 3;
    
    for (int i = 0; i < 3; i ++) {
        
        CGFloat btnX = margin + i * (margin + btnWH);
        
        MtimeButton2 *button = [[MtimeButton2 alloc]init];
        
        [button setImage:self.imageArray[i] forState:UIControlStateNormal];
        
        NSMutableDictionary *dict = [NSMutableDictionary dictionary];
        
        dict[NSFontAttributeName] = [UIFont systemFontOfSize:10];
        


        button.titleLabel.font = [UIFont systemFontOfSize:8];

        
        [button setTitle:self.titleArray[i] forState:UIControlStateNormal];
        
        [button setTitleColor:[UIColor colorWithWhite:0.800 alpha:1.000] forState:UIControlStateNormal];
        
        [self.contentView addSubview:button];
        
        [button mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.top.equalTo(self.contentView).offset(20);
            
            make.bottom.equalTo(self.contentView);
            
            make.left.equalTo(self.contentView).offset(btnX);
            
            make.height.equalTo(@(btnWH)).priorityHigh();
            
            make.width.equalTo(button.mas_height).offset(-25);
            
        }];
        
    }
    
}

@end
